package com.lmf.webservice;

import org.apache.cxf.endpoint.Client;
import org.apache.cxf.frontend.ClientFactoryBean;
import org.apache.cxf.jaxws.JaxWsClientFactoryBean;
import org.apache.cxf.jaxws.JaxWsProxyFactoryBean;

import javax.xml.namespace.QName;
import javax.xml.ws.Service;
import java.net.MalformedURLException;
import java.net.URL;

/**
 * webservice的客户端，去访问一个wsdl文件，并调用其中暴露的Java类方法
 */
public class MainClient {
    public static void main(String[] args) {
        //创建客户端工厂bean
        JaxWsProxyFactoryBean proxyFactoryBean = new JaxWsProxyFactoryBean();
        //设置访问的IP地址
        proxyFactoryBean.setAddress("http://127.0.0.1:9999/lmf_server");
        //设置需要访问的暴露接口class文件
        proxyFactoryBean.setServiceClass(Hello.class);
        //创建代理类，相当于获取暴露的接口类型
        Hello hello = (Hello) proxyFactoryBean.create(); //可以强制转换为暴露接口类型
        String result = hello.sayHelloWorld("刘明福", 22);
        System.out.println(result);
        System.out.println("--------测试成功---------");




    }

//    public static void main(String[] args) throws MalformedURLException {
//
//    }
}
